home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Sources / UFloatWindow.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  5.4 KB  |  186 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UFloatWindow.cp 
  3. // Copyright © 1987-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UFLOATWINDOW__
  7. #include "UFloatWindow.h"
  8. #endif
  9.  
  10. // MacApp
  11.  
  12. #ifndef __GEOMETRY__
  13. #include "Geometry.h"
  14. #endif
  15.  
  16. //    #ifndef __UAPPLICATION__
  17. //    #include "UApplication.h"
  18. //    #endif
  19.  
  20. #ifndef __UCOREGLOBALS__
  21. #include "UCoreGlobals.h"
  22. #endif
  23.  
  24. #ifndef __UDISPATCHER__
  25. #include "UDispatcher.h"
  26. #endif
  27.  
  28. #ifndef __UMACAPPGLOBALS__
  29. #include "UMacAppGlobals.h"
  30. #endif
  31.  
  32. //    #ifndef __UMACAPPUTILITIES__
  33. //    #include "UMacAppUtilities.h"
  34. //    #endif
  35.  
  36. // Toolbox
  37.  
  38. #ifndef __TOOLUTILS__
  39. #include <ToolUtils.h>
  40. #endif
  41.  
  42. //----------------------------------------------------------------------------------------
  43. Boolean gUFloatWindowInitialized;        // declared in header
  44.  
  45. //----------------------------------------------------------------------------------------
  46.  
  47. //========================================================================================
  48. // CLASS TFloatWindow
  49. //========================================================================================
  50. #undef Inherited
  51. #define Inherited TWindow
  52.  
  53. #pragma segment MAOpen
  54. MA_DEFINE_CLASS_M1(TFloatWindow, Inherited);
  55.  
  56. //----------------------------------------------------------------------------------------
  57. // TFloatWindow constructor
  58. //----------------------------------------------------------------------------------------
  59. #pragma segment MAOpen
  60.  
  61. TFloatWindow::TFloatWindow()
  62. {
  63.     // Override default value for fResizeLimits
  64.     fResizeLimits[topLeft] = CPoint(1, 1);
  65.     
  66.     fHideOnSuspend = TRUE;
  67.     fDoFirstClick = TRUE;
  68.     fFloats = TRUE;
  69.     fGenerateActivates = FALSE;
  70.     fOMClassID = cPalette;            // Establish AEOM class ID
  71. } // TFloatWindow::TFloatWindow
  72.  
  73. //----------------------------------------------------------------------------------------
  74. // TFloatWindow destructor
  75. //----------------------------------------------------------------------------------------
  76. #pragma segment MADestructorRes
  77.  
  78. TFloatWindow::~TFloatWindow()
  79. {
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------
  83. // TFloatWindow::IFloatWindow: 
  84. //----------------------------------------------------------------------------------------
  85. #pragma segment MAOpen
  86.  
  87. void TFloatWindow::IFloatWindow(TDocument* itsDocument,
  88.                                        WindowRef itsWMgrWindow,
  89.                                        Boolean canResize,
  90.                                        Boolean canClose,
  91.                                        Boolean disposeOnFree)
  92. {
  93.     this->IWindow(itsDocument, itsWMgrWindow, canResize, canClose, disposeOnFree);
  94.     SetWindowKind(itsWMgrWindow,kFloatingWindowKind);// mark it as a floating window 
  95.  
  96. } // TFloatWindow::IFloatWindow 
  97.  
  98. //----------------------------------------------------------------------------------------
  99. // TFloatWindow::GetStandardSignature: 
  100. //----------------------------------------------------------------------------------------
  101. #pragma segment MAWriteResource
  102.  
  103. IDType TFloatWindow::GetStandardSignature()// override 
  104. {
  105.     return kStdFloatWindow;
  106. } // TFloatWindow::GetStandardSignature 
  107.  
  108. //----------------------------------------------------------------------------------------
  109. // TFloatWindow::ReadFields: 
  110. //----------------------------------------------------------------------------------------
  111. #pragma segment MAReadResource
  112.  
  113. void TFloatWindow::ReadFields(TStream* aStream)// override 
  114. {
  115.     Inherited::ReadFields(aStream);
  116.  
  117.     SetWindowKind(fWMgrWindow, kFloatingWindowKind);// mark it as a floating window 
  118. } // TFloatWindow::ReadFields 
  119.  
  120. //----------------------------------------------------------------------------------------
  121. // TFloatWindow::GetBehindWindowPtr: 
  122. //----------------------------------------------------------------------------------------
  123. #pragma segment MAOpen
  124.  
  125. WindowRef TFloatWindow::GetBehindWindowPtr()
  126.  
  127. {
  128.     // bring the float window up in front of all other windows
  129.     return (WindowRef) - 1;                        
  130. } // TFloatWindow::GetBehindWindowPtr 
  131.  
  132. //----------------------------------------------------------------------------------------
  133. // TFloatWindow::Close: 
  134. //----------------------------------------------------------------------------------------
  135. #pragma segment MAClose
  136.  
  137. void TFloatWindow::Close()    // Override 
  138.  
  139. {
  140.     Inherited::Close();
  141.     
  142.     TEventHandler* activeTarget = NULL;
  143.     
  144.     TWindow* activeWindow = gDispatcher->GetActiveWindow(!kFloatersOK);
  145.     
  146.     // Non-floater is always targettable.
  147.     if (activeWindow)
  148.         activeTarget = activeWindow->GetWindowTarget();
  149.     
  150.     if (activeTarget != NULL)
  151.     {
  152.         gDispatcher->SetTarget(activeTarget);
  153.         activeTarget->SetTargetSelection(kRedraw);
  154.     }
  155.     else
  156.         gDispatcher->SetTarget(gDispatcher);
  157. } // TFloatWindow::Close 
  158.  
  159.  
  160. //========================================================================================
  161. // GLOBAL Procedures
  162. //========================================================================================
  163. #undef Inherited
  164.  
  165. //----------------------------------------------------------------------------------------
  166. // InitUFloatWindow:
  167. //----------------------------------------------------------------------------------------
  168. #pragma segment MAWindowRes
  169.  
  170. void InitUFloatWindow()
  171. {
  172.     if (gUFloatWindowInitialized)
  173.         return;
  174.  
  175. #if qTemplateViews
  176.     MA_REGISTER_SIGNATURE(TFloatWindow, kStdFloatWindow);
  177. #endif
  178.  
  179.     gUFloatWindowInitialized = TRUE;
  180. } // InitUFloatWindow 
  181.  
  182. //----------------------------------------------------------------------------------------
  183. // End of UFloatWindow.cp
  184.  
  185. #pragma segment Inline
  186.